package com.dstz.demo.rest.controller;

import com.dstz.base.api.aop.annotion.CatchErr;
import com.dstz.base.api.response.impl.ResultMsg;
import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.ClcsbManager;
import com.dstz.demo.core.manager.ClparameterManager;
import com.dstz.demo.core.model.Clcsb;
import com.dstz.demo.core.model.Clparameter;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sys/clcsb")
public class ClcsbController extends BaseController<Clcsb> {

    @Resource
    ClcsbManager clcsbManager;
    @Resource
    ClparameterManager clparameterManager;

    @Override
    protected String getModelDesc() {
        return null;
    }
    @PostMapping("/getinfo/{id}")
    @CatchErr(write2response = true,value = "查询信息失败")
    public ResultMsg<List<Clparameter>> findinfo(@PathVariable("id") String materielcodeid){
//        List<Xmprocedure> list= xmprocedureManager.getAll();
        List<Clparameter> list=new ArrayList<>();
        List<Clparameter> clcsbs=clparameterManager.query(materielcodeid);
//        List<Clparameter> clcsbss=new ArrayList<>();
//        if(materielcodeid.lastIndexOf(".")>-1){
//            String materielcodeids=materielcodeid.substring(0,materielcodeid.lastIndexOf("."));
//            clcsbss=clparameterManager.query(materielcodeids);
//        }else{
//            clcsbss=clparameterManager.query(materielcodeid);
//        }
        list.addAll(clcsbs);
//        list.addAll(clcsbss);
        return getSuccessResult(list);
    }
}
